// 房型模块
const {
	RoomType
} = require('../../../model/RoomType');

module.exports = async (req, res) => {
	const {
		isBed = false, title = ''
	} = req.query;
	// 查询房型信息
	const types = await RoomType.find({
		$and: [{
				isBed
			},
			{
				// 利用正则表达式对房型名称进行模糊查询
				title: {
					$regex: new RegExp(title, 'i')
				}
			}
		]
	}).populate('children').sort('-title');
	// 响应
	res.sendResult(types, 200, '获取房型列表信息成功');
}